home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue28 / yearcal / YEARCAL.ZIP / YEARCAL.DOC < prev    next >
Encoding:
Text File  |  1997-10-20  |  6.3 KB  |  183 lines

  1. {======================================================|
  2. | Year Calendar, 1.2 - (c) 1996 by Alvaro L. S. Almeida|
  3. |------------------------------------------------------|
  4. | Display a whole year's calendar, in Delphi programs. |
  5. | For Delphi 1, 2 e 3 (16 and 32 bits)                 |
  6. |                                                      |
  7. | See other components in our home-page.               |
  8. |------------------------------------------------------|
  9. | DROID Informatica ltda - Rio de Janeiro - Brazil     |
  10. |                                                      |
  11. | Home Page: http://www.di.com.br                      |
  12. | E-Mail:    comp@di.com.br                            |
  13. | Fax:       055 021 224-0331                          |
  14. |======================================================}
  15.  
  16. {$R-,S-,Q-,V-,X+,P+}
  17.  
  18. unit YearCal;
  19.  
  20. interface
  21.  
  22. uses
  23.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  24.   Forms, Dialogs;
  25.  
  26. type
  27.   TMyNotifyEvent = procedure(Sender: TObject; SelectedDate: TDateTime) of object;
  28.   TMyMouseEvent  = procedure(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
  29.                                X, Y: Integer; SelectedDate: TDateTime) of object;
  30.  
  31.   TDRBorder  = (boNone, boSingle, boRaised, boLowered);
  32.   TDRYearCal = class(TGraphicControl)
  33.   private
  34.     FH,             { Font Height }
  35.     FW,             { Font Width  }
  36.     MH,             { Month Height}
  37.     MW: integer;    { Month Width }
  38.  
  39.     CurYear,                 { Current Year  }
  40.     CurMonth,                { Current Month }
  41.     CurDay         : word;   { Current Day   }
  42.  
  43.     FDate          : TDateTime;
  44.     FMonthColor    : TColor;
  45.     FWeekColor     : TColor;
  46.     FSundayColor   : TColor;
  47.     FSaturdayColor : TColor;
  48.     FLineColor     : TColor; { Only if (border = boSingle) or (Ctl3D = false) }
  49.     FCurDayColor   : TColor; { Current day color }
  50.  
  51.     FBorder        : TDRBorder;
  52.     FCtl3D,
  53.     FLines         : boolean;{ If TRUE, show lines between months}
  54.     FYear          : integer;
  55.     GapVert        : byte;   { Number of pixels between two days }
  56.     GapHorz        : byte;   { Number of pixels between two days }
  57.     FCol           : byte;   { Number of columns (default = 4)   }
  58.     FDispYear      : boolean;{ If TRUE, display year beside month name }
  59.  
  60.     GapMonthVert   : byte;   { Number of pixels between two months }
  61.     GapMonthHorz   : byte;   { Number of pixels between two months }
  62.  
  63.     FOnMouseDown   : TMyMouseEvent;
  64.     FOnMouseUp     : TMyMouseEvent;
  65.     FOnClick       : TMyNotifyEvent;
  66.     FOnDblClick    : TMyNotifyEvent;
  67.  
  68.     procedure SetNumCol(Value: Byte);
  69.     procedure SetYear(Value: integer);
  70.     procedure SetMonthColor(Value: TColor);
  71.     procedure SetSundayColor(Value: TColor);
  72.     procedure SetSaturdayColor(Value: TColor);
  73.     procedure SetWeekColor(Value: TColor);
  74.     procedure SetCurDayColor(Value: TColor);
  75.     procedure SetLineColor(Value: TColor);
  76.     procedure SetVertDayGap(Value: Byte);
  77.     procedure SetHorzDayGap(Value: Byte);
  78.     procedure SetVertMonthGap(Value: Byte);
  79.     procedure SetHorzMonthGap(Value: Byte);
  80.     procedure SetLines(Value: Boolean);
  81.     procedure SetDisplayYear(value:boolean);
  82.     procedure SetCtl3D(value:boolean);
  83.     procedure GetSelectedDate(x,y: integer);
  84.     procedure PaintDay(DoPaint:boolean);
  85.     procedure SetBorder(Value: TDRBorder);
  86.  
  87.   protected
  88.     procedure Paint; override;
  89.     procedure MouseDown(Button:TMouseButton; Shift:TShiftState;
  90.                         X, Y: Integer);  Override;
  91.     procedure MouseUp  (Button:TMouseButton; Shift:TShiftState;
  92.                         X, Y: Integer);  Override;
  93.     procedure Click; Override;
  94.     procedure DblClick; Override;
  95.  
  96.   public
  97.     constructor Create(AOwner: TComponent); override;
  98.     procedure DispMonth(month,c,l:integer);   { Display a month at the specified column (C) and line (L) }
  99.  
  100.   published
  101.     property Enabled;
  102.     property Visible;
  103.     property Font;
  104.     property Color;
  105.     property ShowHint;
  106.  
  107.     property DisplayYear:  boolean read  FDispYear
  108.                                    write SetDisplayYear;
  109.  
  110.     property Ctl3D:        boolean read  FCtl3D
  111.                                    write SetCtl3D;
  112.  
  113.     property MonthColor:   TColor  read  FMonthColor
  114.                                    write SetMonthColor;
  115.  
  116.     property SaturdayColor:TColor  read  FSaturdayColor
  117.                                    write SetSaturdayColor;
  118.  
  119.     property SundayColor:  TColor  read  FSundayColor
  120.                                    write SetSundayColor;
  121.  
  122.     property WeekColor:    TColor  read  FWeekColor
  123.                                    write SetWeekColor;
  124.  
  125.     property CurDayColor:  TColor  read  FCurDayColor
  126.                                    write SetCurDayColor;
  127.  
  128.     property LineColor:    TColor  read  FLineColor
  129.                                    write SetLineColor;
  130.  
  131.     property NumColumns:   Byte    read    FCol
  132.                                    write   SetNumCol
  133.                                    default 4;
  134.  
  135.     property Year:         integer read    FYear
  136.                                    write   SetYear
  137.                                    default 1997;
  138.  
  139.     property VertDayGap:   byte    read  GapVert
  140.                                    write SetVertDayGap;
  141.  
  142.     property HorzDayGap:   byte    read  GapHorz
  143.                                    write SetHorzDayGap;
  144.  
  145.     property VertMonthGap: byte    read  GapMonthVert
  146.                                    write SetVertMonthGap;
  147.  
  148.     property HorzMonthGap: byte    read  GapMonthHorz
  149.                                    write SetHorzMonthGap;
  150.  
  151.     property Lines :       boolean read  FLines
  152.                                    write SetLines;
  153.  
  154.     property Border:     TDRBorder read  FBorder
  155.                                    write SetBorder;
  156.  
  157.     property OnMouseDown: TMyMouseEvent read FOnMouseDown write FOnMouseDown;
  158.     property OnMouseUp: TMyMouseEvent read FOnMouseUp write FOnMouseUp;
  159.     property OnClick: TMyNotifyEvent read FOnClick write FOnClick;
  160.     property OnDblClick: TMyNotifyEvent read FOnDblClick write FOnDblClick;
  161.   end;
  162.  
  163. procedure Register;
  164.  
  165. implementation
  166.  
  167. uses
  168.   ExtCtrls;
  169.  
  170. const
  171.   MaxDay : array[1..12] of byte = (31,28,31,30,31,30,31,31,30,31,30,31);
  172.  
  173.  
  174.   { . . . }
  175.  
  176.  
  177. procedure Register;
  178. begin
  179.   RegisterComponents('DROID', [TDRYearCal]);
  180. end;
  181.  
  182. end.
  183.